import { VNodeProps } from 'vue'
import { ElInput, ElCascader, ElDatePicker } from 'element-plus'
import GSelect from '@/components/GSelect/index.vue'
import GDateRangePicker from '@/components/GDateRangePicker/index.vue'

const COMPONENT_MAP: Record<string, VNodeProps> = {
  input: ElInput,
  select: GSelect,
  datePicker: ElDatePicker,
  dateRangePicker: GDateRangePicker,
  cascader: ElCascader
}

export const getCustomInput = (is?: string | VNodeProps): string | VNodeProps => {
  if (!is) {
    return COMPONENT_MAP.input
  }
  if (typeof is === 'string') {
    return COMPONENT_MAP[is] ?? is
  }
  return is
}
